#include <cctype>
#include <cstdio>

typedef long long ll;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 2e6 + 5;
int fac[N], pri[N / 10], tot[N], p, n, cnt;

ll qpow(ll base, int index) {
  ll res = 1;
  while (index) {
    if (index & 1) res = res * base % p;
    base = base * base % p;
    index >>= 1;
  }
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3200 [HNOI2009]有趣的数列.in", "r", stdin);
  freopen("P3200 [HNOI2009]有趣的数列.out", "w", stdout);
#endif
#endif

  read(n), read(p);
  for (int i = 2; i <= 2 * n; i++) {
    if (!fac[i]) { pri[++cnt] = i, fac[i] = i; }
    for (int j = 1; j <= cnt && i * pri[j] <= n << 1; j++) {
      fac[i * pri[j]] = pri[j];
      if (i % pri[j] == 0) break;
    }
  }
  for (int i = 1; i <= n; i++) tot[i] = -1;
  for (int i = n + 2; i <= 2 * n; i++) tot[i] = 1;
  for (int i = 2 * n; i > 1; i--)
    if (fac[i] < i) {
      tot[fac[i]] += tot[i];
      tot[i / fac[i]] += tot[i];
    }
  ll ans = 1;
  for (int i = 2; i <= 2 * n; i++)
    if (fac[i] == i) ans = ans * qpow(i, tot[i]) % p;
  printf("%lld", ans);
  return 0;
}